#if defined(OS400)
#pragma convert(850)
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* C include files */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include<malloc.h>

/* Lotus C API for Domino and Notes include files */

#include <global.h>
#include <nsfdb.h>
#include <nsfnote.h>
#include <nsfobjec.h>
#include <nsfsearc.h>
#include <osmem.h>
#include <nsferr.h>
#include <osfile.h> 
#include <kfm.h>
#include <osmisc.h>
#include <ods.h>

#if defined(OS390)
#include <_Ascii_a.h>    /* NOTE: must be the LAST file included */
#include <lapicinc.h>
#endif /* OS390 */

              
#define  STRING_LENGTH  256

/* Data prototypes */

#define MailMsg struct MailMessage
MailMsg {
	long* id;
	char* from;
	char* to;
	char* copyTo;
	char* blindCopyTo;
	char* subject;
	char* body;
	char* attachments;
	char* postedDate;
	MailMsg *next;
};

#define LEN sizeof (struct MailMessage)

#define Para struct Parameters
Para {
	DBHANDLE* db_handle;
	KFHANDLE* phKFC;
	MailMsg*  mm;
};

/* Function prototypes */

int getMailMessages (char* serverName, char* dbName, char* password, MailMsg *mm);

int handleMailDB(char *szMailFilePath, char* serverName,char *password, MailMsg *mm);

int handleSecurity(char* serverName,char* password, DBHANDLE db_handle,MailMsg *mm);

int searchMailMessages(DBHANDLE db_handle,KFHANDLE	*phKFC,MailMsg *mm);

STATUS LNPUBLIC parseMailMessage(void far *,SEARCH_MATCH far *pSearchMatch,ITEM_TABLE far *summary_info);

void getFieldContent(NOTEHANDLE  note_handle,char *item_name,char **item_content);

void extractSingleAttachment(NOTEHANDLE  note_handle,NOTEID noteID,BLOCKID item_blockid,BLOCKID value_blockid,char*);

void extractAttachments(NOTEHANDLE  note_handle,NOTEID noteID,char*);

void PrintAPIError (STATUS api_error);


#ifdef __cplusplus
}
#endif